home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #1 / Amiga Plus 1999 #1.iso / System-Boost / Graphics / FlashMandel / Sources / Modules / MandReal.S < prev    next >
Encoding:
Text File  |  1998-06-28  |  3.7 KB  |  99 lines

  1. ************************************************************************
  2. **            Written by Dino Papararo            30-Apr-1998
  3. **
  4. **  FUNCTION
  5. **
  6. **    MandReal -- perform Z = Z^2 + C iteration.
  7. **
  8. **  SYNOPSIS
  9. **
  10. **    WORD MandFPU (WORD Iterations,long double Cre,long double Cim)
  11. **
  12. **
  13. **  DESCRIPTION
  14. **
  15. **  C equivalent function:
  16. **
  17. **    *************************************************************
  18. **    *WORD Real (WORD Iterazioni,long double Cre,long double Cim)*
  19. **    *{                                                          *
  20. **    *register long double zr,zi,zr2,zi2;                        *
  21. **    *                                                           *
  22. **    *  zr = Cre;                                                *
  23. **    *                                                           *
  24. **    *  zi = Cim;                                                *
  25. **    *                                                           *
  26. **    *  zr2 = Cre * Cre;                                         *
  27. **    *                                                           *
  28. **    *  zi2 = Cim * Cim;                                         *
  29. **    *                                                           *
  30. **    *  while ((zr2 + zi2 <= 4.0))                               *
  31. **    *  {                                                        *
  32. **    *     if (--Iterazioni == 0) break;                         *
  33. **    *                                                           *
  34. **    *     zi *= zr;                                             *
  35. **    *                                                           *
  36. **    *     zr  = zr2 - zi2 + Cre;                                *
  37. **    *                                                           *
  38. **    *     zi += zi + Cim;                                       *
  39. **    *                                                           *
  40. **    *     zr2 = zr * zr;                                        *
  41. **    *                                                           *
  42. **    *     zi2 = zi * zi;                                        *
  43. **    *  }                                                        *
  44. **    *                                                           *
  45. **    *  return Iterazioni;                                       *
  46. **    *}                                                          *
  47. **    *************************************************************
  48. **
  49. **  This function tests if a point belongs or not at mandelbrot's set
  50. **
  51. **  Optimized for pipelines of 68882+ coprocessors
  52. **
  53. **  NOTICE: ALL VARIABLES ARE INTO REGISTERS FOR FULL SPEEEED
  54. **
  55. **  d0:Iterations
  56. **
  57. **  fp0:Cre fp1:Cim fp2:Zr fp3:Zi fp4:Zr2 fp5:Zi2 fp6:Dist fp7:MaxDist
  58. ************************************************************************
  59.  
  60.  
  61.  
  62.         XDEF  _MandFPU
  63.  
  64. _MandFPU:
  65.  
  66.         fmove.x fp0,fp4  * Zr2 = Cre
  67.         fmove.x fp1,fp5  * Zi2 = Cim
  68.         fmove.b #4,fp7   * MaxDist = 4
  69.         fmul.x  fp4,fp4  * Zr2 *= Zr2
  70.         fmul.x  fp5,fp5  * Zi2 *= Zi2
  71.         fmove.x fp0,fp2  * Zr = Cre
  72.         fmove.x fp1,fp3  * Zi = Cim
  73.        
  74. Loop:
  75.         fmove.x fp5,fp6  * Dist = Zi2
  76.         fadd.x  fp4,fp6  * Dist += Zr2
  77.         fcmp.x  fp7,fp6  * Compare Dist with MaxDist
  78.         fbgt.w  Exit     * if Dist > MaxDist Exit
  79.         
  80.         fmul.x  fp2,fp3  * Zi *= Zr
  81.         fmove.x fp4,fp2  * Zr = Zr2
  82.         fadd.x  fp3,fp3  * Zi += Zi
  83.         fsub.x  fp5,fp2  * Zr -= Zi2
  84.         fadd.x  fp1,fp3  * Zi += Cim
  85.         fadd.x  fp0,fp2  * Zr += Cre
  86.  
  87.         fmove.x fp3,fp5  * Zi2 = Zi
  88.         fmove.x fp2,fp4  * Zr2 = Zr
  89.         fmul.x  fp5,fp5  * Zi2 *= Zi2
  90.         fmul.x  fp4,fp4  * Zr2 *= Zr2
  91.  
  92.         dbra.w  d0,Loop  * if --Iterations go to Loop
  93.         moveq.l #0,d0    * Iterations = 0
  94.         
  95. Exit:
  96.         rts  * return Iterations
  97.  
  98.         end
  99.